<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object.fromEntries</title>
</head>

<body>
    <script>
        //二维数组
        // const result = Object.fromEntries([
        //     ['name', '尚硅谷'],
        //     ['xueke', 'JAVA,大数据,前端，云计算']
        // ]);

        //Map
        // const m = new Map();
        // m.set('name', 'ATGUIGU');
        // const result = Object.fromEntries(m);  //将二维数组转为对象

        //Object.entries  ES8
        const arr = Object.entries({ //将对象转为二维数组
            name: '尚硅谷'
        });
        console.log(arr);

        //字符串扩展方法  trimStart 和 trimEnd
        let str = '      iloveyou       ';
        console.log(str);
        console.log(str.trimStart());
        console.log(str.trimEnd());

        //flat平
        //将多维数组转为低维数组  参数为深度，是一个数字
        const arr1 = [1, 2, 3, 4, [5, 6, [7, 8]]];
        console.log(arr1.flat(2));

        //flatMap
        const arr2 = [1, 2, 3, 4];
        // const result = arr2.map(item => [item * 10]);  //返回一个二维数组
        const result = arr2.flatMap(item => [item * 10]); //如果map返回结果是个多维数组，flatMap可以把这个多维数组变为一维。
        console.log(result);


        //创建Symbol
        let s = Symbol('尚硅谷');
        console.log(s.description);
    </script>
</body>

</html>